﻿<%@ Page Language="C#" AutoEventWireup="true" masterpagefile="~/Admin/Main.master"  title="栏目管理" CodeFile="MenuList.aspx.cs" Inherits="Admin_MenuList" %>

<%@ Register TagPrefix="uc" TagName="ContentMenu" Src="~/Admin/ContentMenu.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftMenu" Runat="Server">
    <uc:ContentMenu ID="ContentMenu" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MidContent" Runat="Server">
  <div id="mainMenu">
  	<ul>
		<li><a href="MenuAdd.aspx">添加栏目</a></li><li><a href="MenuList.aspx">栏目列表</a></li></ul>
  </div>
   <div id="main">
   <asp:Label id="Msg" runat="server" Text="" CssClass="msg" Visible="False"></asp:Label>
    <asp:GridView ID="MenuList" runat="server" AllowPaging="True" AutoGenerateColumns="False" OnPageIndexChanging="MenuList_PageIndexChanging" DataKeyNames="MenuId" OnRowCancelingEdit="MenuList_RowCancelingEdit" OnRowEditing="MenuList_RowEditing" OnRowUpdating="MenuList_RowUpdating" PageSize="11" OnRowDeleting="MenuList_RowDeleting" CellPadding="0" CssClass="gv" Width="100%" OnRowDataBound="MenuList_RowDataBound" EmptyDataText="暂无任何栏目" >
        <Columns>
            <asp:BoundField DataField="OrderId" HeaderText="排序号" >
                <ControlStyle CssClass="gvOrderId" />
            </asp:BoundField>
            <asp:BoundField DataField="MenuName" HeaderText="栏目名称" />
            <asp:TemplateField HeaderText="栏目标识">
                <EditItemTemplate>
                    <asp:TextBox ID="FileName" runat="server" Text='<%# Bind("FileName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="FileName"
                        Display="Dynamic" ErrorMessage="必须填写"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="FileName"
                        Display="Dynamic" ErrorMessage="栏目标识必须为小写字母或下划线组成" ValidationExpression="[a-z_]{0,50}"></asp:RegularExpressionValidator>
                    <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="FileName"
                        Display="Dynamic" ErrorMessage="已存在此标识" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("FileName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="栏目位置">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# MenuProvider.GetLocation(Eval("Location").ToString()) %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# MenuProvider.GetLocation(Eval("Location").ToString()) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="栏目类型">
                <EditItemTemplate>
                    <asp:HiddenField ID="AttributerHiddenField" runat="server" Value='<%# Eval("Attributer") %>' />
                    <asp:Label ID="Label2" runat="server" Text='<%# MenuProvider.GetAttributer(Eval("Attributer").ToString()) %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:HiddenField ID="AttributerHiddenField" runat="server" Value='<%# Eval("Attributer") %>' />
                    <asp:Label ID="Label2" runat="server" Text='<%# MenuProvider.GetAttributer(Eval("Attributer").ToString()) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="Encrypt" HeaderText="是否加密" >
                <ControlStyle CssClass="checkBox" />
            </asp:CheckBoxField>
            <asp:CheckBoxField DataField="Show" HeaderText="是否显示" >
                <ControlStyle CssClass="checkBox" />
            </asp:CheckBoxField>
            <asp:TemplateField HeaderText="打开方式">
                <EditItemTemplate>
                    <asp:HiddenField ID="TargetHiddenField" runat="server" Value='<%# Eval("Target") %>' />
                    <asp:DropDownList ID="TargetList" runat="server">
                    </asp:DropDownList>&nbsp;
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# MenuProvider.GetTarget(Eval("Target").ToString()) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="href" HeaderText="链接地址" NullDisplayText="无" />
            <asp:TemplateField HeaderText="操作" ShowHeader="False">
                <EditItemTemplate>
                    <asp:Button ID="UpdateBt" runat="server" CausesValidation="True" CommandName="Update"
                        Text="更新" />
                    <asp:Button ID="CancelBt" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="取消" />    
                </EditItemTemplate>
                <ItemStyle CssClass="gvCommandField" />
                <ItemTemplate>
                    <asp:Button ID="EditBt" runat="server" Text="编辑" CausesValidation="false" CommandName="Edit" />
                    <asp:Button ID="DelBt" runat="server" CausesValidation="False" CommandName="Delete" Text="删除" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <RowStyle CssClass="gvRow" />
        <EditRowStyle CssClass="gvEditRow" />
        <PagerStyle CssClass="gvPage" />
        <HeaderStyle CssClass="gvHeader" />
        <AlternatingRowStyle CssClass="gvAlternatingRow" />
    </asp:GridView>
  </div>
  <script language="JavaScript" type="text/javascript" >
        topMenuThisPage(2);//当前位置顶部菜单标识
        leftMenuThisPage(1,1);//当前位置左侧菜单标识
        mainMenuThisPage(2);//当前选项卡标识
  </script>
</asp:Content>